package de.mhus.lib.core.lang;

import de.mhus.lib.core.base.BaseFindStrategy;
import de.mhus.lib.core.base.InjectStrategy;
import de.mhus.lib.core.base.NoInjectionStrategy;
import de.mhus.lib.core.base.SingleBaseStrategy;

public class BaseControl {

	private static BaseFindStrategy findStrategy = new SingleBaseStrategy();
	private static InjectStrategy injectStrategy = new NoInjectionStrategy();
	
	public static Base base(Object owner) {
		return findStrategy.find(owner);
	}

	public static void setFindStrategy(BaseFindStrategy strategy) {
		findStrategy = strategy;
	}
	
	public static void setInjectStrategy(InjectStrategy strategy) {
		injectStrategy = strategy;
	}
	
	public static InjectStrategy getInjectStrategy() {
		return injectStrategy;
	}
	
	public static BaseFindStrategy getFindStrategy() {
		return findStrategy;
	}
	
	
	public static Base createBase(MObject mObject, Base parent) {
		Base newBase = new Base(parent);
		return newBase;
	}

	public static Base installBase(Base base) {
		return findStrategy.install(base);
	}
	
	public static Base getBaseOf(MObject obj) {
		return obj.base();
	}
	
	public static Base getCurrentBase() {
		return findStrategy.find();
	}

	public static void inject(Object object, Base base) {
		injectStrategy.inject(object, base);
	}
	
}
